public class Person{
    String name;
    char gender;
    int age;
    boolean married;

    public void marry(Person another){
        if(this.married==false && another.married==false){
            if(this.gender=='男'){
                if(this.age>=22){
                    if(another.gender=='女'){
                        if(another.age>=20){
                              System.out.println(this.name+"可以和"+another.name+"结婚！");
                        }else{
                            System.out.println("女方年龄未满20岁，不能结婚");
                        }
                      
                    }else if(another.gender=='男'){
                        System.out.println("两个男人不能结婚！");
                    }
                }else{
                    System.out.println("男方年龄未满22周岁，不能结婚！");
                }
            }else if(this.gender=='女'){
                if(this.age>=20){
                    if(another.gender=='男'){
                        if(another.age>=22){
                            System.out.println(this.name+"可以和"+another.name+"结婚！");
                      }else{
                          System.out.println("男方年龄未满22岁，不能结婚");
                      }
                    }else if(another.gender=='女'){
                        System.out.println("两个女人不能结婚！");
                    }
                }else{
                    System.out.println("女方年龄未满20周岁，不能结婚！");
                }
            }
        }else{
            if(this.gender=='男'&&this.married==true){
                System.out.println("男方"+this.name+"已结婚，不能再结婚！");
            }
            if(another.gender=='女'&&another.married==true){
                System.out.println("女方"+another.name+"已结婚，不能再结婚！");
            }
            if(this.gender=='女'&&this.married==true){
                System.out.println("女方"+this.name+"已结婚，不能再结婚！");
            }
            if(another.gender=='男'&&another.married==true){
                System.out.println("男方"+another.name+"已结婚，不能再结婚！");
            }
           
        }
    }
    public static void main(String[] args) {
        Person first=new Person();
        Person second=new Person();
        first.name="罗志祥";
        first.age=30;
        first.gender='男';
        first.married=false;

        second.name="周扬青";
        second.age=22;
        second.gender='女';
        second.married=false;

        first.marry(second);

    }
}